<template>
  <view class="notice">
    <template v-if="list.length">
      <view v-for="i of list" :key="i.id" class="notice-item">
        <view class="header flex-row">
          <view class="remind">{{ i.title }}</view>
          <view class="date">{{ i.create_at }}</view>
        </view>
        <view class="divider"></view>
        <view class="cont">{{ i.content }}</view>
      </view>
      <uni-load-more icon-type="circle" :status="loadStatus" />
    </template>
    <view v-else class="no-data">暂无数据</view>
  </view>
</template>

<script setup>
import { onReachBottom } from '@dcloudio/uni-app'
import { fetchMessageList } from '@/api'
import { useList } from '@/hooks/useList'

const { list, loadStatus, getFirstList, getMoreList } =
  useList(fetchMessageList)

getFirstList()

onReachBottom(getMoreList)
</script>

<style scoped lang="scss">
.notice {
  .notice-item {
    margin: 30rpx;
    padding: 30rpx;
    border-radius: 10rpx;
    background-color: #fff;
    .header {
      .remind {
        color: #333;
        font-weight: bold;
        display: flex;
        align-items: center;
        column-gap: 14rpx;
        &::before {
          content: '';
          display: block;
          width: 16rpx;
          height: 16rpx;
          border-radius: 50%;
          background-color: #377dff;
        }
      }
      .date {
        color: #999;
        font-size: 26rpx;
      }
    }
    .divider {
      margin-top: 30rpx;
      margin-bottom: 30rpx;
      border-top: 2rpx solid #efefef;
    }
    .cont {
      color: #666;
      font-size: 28rpx;
    }
  }
}
</style>
<style>
page {
  background-color: #f8f8f8;
}
</style>
